Skip to content

ci(security): add Bandit static analysis workflow.#365

Open
kefaslungu wants to merge 3 commits intoEAPD-DRB:mainfrom
kefaslungu:feature/58-bandit-security-scan
Open

ci(security): add Bandit static analysis workflow.#365
kefaslungu wants to merge 3 commits intoEAPD-DRB:mainfrom
kefaslungu:feature/58-bandit-security-scan

Conversation

@kefaslungu
Copy link
Copy Markdown

Linked issue

Existing related work reviewed

Overlap assessment

Why this PR should proceed

  • The codebase has no automated security analysis. Every PR to main currently
    merges without any check for high-severity Python vulnerabilities.
  • This workflow catches real issues: one High (B201 flask debug=True) and two
    Medium (B104 hardcoded bind-all-interfaces) were found in the existing
    codebase during development of this PR.
  • SARIF output integrates directly with GitHub's Security tab, surfacing
    findings inline on future PRs without requiring contributors to read logs.

Summary

  • What changed:
    • .github/workflows/bandit.yml — Bandit security scan workflow triggered on
      push/PR to main and manually via workflow_dispatch. Fails on High severity,
      reports Medium/Low as non-blocking. Outputs SARIF to GitHub Security tab
      and uploads full report as artifact. Bandit and formatter versions pinned.
      Pip dependencies cached.
    • API/app.py added # nosec B201 to suppress known,
      accepted High finding in the dev-only Flask fallback path.
    • .gitignore — added *.sarif to exclude generated scan artifacts.
  • Why: Establishes a security baseline and ensures all future PRs are
    automatically scanned for high-severity Python vulnerabilities.

Validation

  • Tests added/updated (not applicable — workflow validated locally)
  • Validation steps documented
  • Evidence attached (logs/screenshots/output as relevant)

Local validation:

  • bandit -r API/ --severity-level high → exit 0, no issues after nosec annotation

  • bandit -r API/ --severity-level low → exit 1 (findings exist), handled correctly

  • Both SARIF files verified as valid JSON

  • Docs updated in this PR (not applicable)

  • Any setup/workflow changes reflected in repo docs (workflow is self-documenting)

Scope check

  • No unrelated refactors
  • Implemented from a feature branch (feature/58-bandit-security-scan)
  • Change is deliverable without upstream OSeMOSYS/MUIO dependency
  • Base repo/branch is EAPD-DRB/MUIOGO:main (not upstream)

Exception rationale

  • Leave blank otherwise.

Signed-off-by: kefaslungu <jameskefaslungu@gmail.com>
Signed-off-by: kefaslungu <jameskefaslungu@gmail.com>
Signed-off-by: kefaslungu <jameskefaslungu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant